<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>兄弟选择器</title>
    <style>
        body {
            width: 50%;
            height: 100vh;
            margin: 0 auto;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        .main {
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }

        p+span {
            /* 样式作用于p标签之后紧挨着的span标签 */
            color: red;
        }

        .p1~span {
            /* 样式作用于p1后所有兄弟span元素 */
            font-size: 30px;
        }
    </style>
</head>

<body>
    <div class="main">

        <p class="p1">p1</p>
        <span>span1</span>
        <p>p2</p>
        <span>span2</span>
        <p>p3</p>
        <p>p4</p>
        <div>div1</div>
        <span>span3</span>
        <p>p5</p>
    </div>
    <span>span4</span>

</body>

</html>